#ifndef _MYIIC_H_
#define _MYIIC_H_

#include "main.h"
#include "tim.h"

//#define IIC3_SCL      PAout(8)
//#define IIC3_SDA_OUT  PCout(9)
//#define IIC3_SDA_IN   PCin(9)

#define  IIC3_SDA_LOW()  HAL_GPIO_WritePin(GPIOC,GPIO_PIN_9,GPIO_PIN_RESET)
#define  IIC3_SDA_HIGH() HAL_GPIO_WritePin(GPIOC,GPIO_PIN_9,GPIO_PIN_SET)
#define  IIC3_SCK_LOW()  HAL_GPIO_WritePin(GPIOA,GPIO_PIN_8,GPIO_PIN_RESET)
#define  IIC3_SCK_HIGH() HAL_GPIO_WritePin(GPIOA,GPIO_PIN_8,GPIO_PIN_SET)
#define      IIC3_SDA_IN     HAL_GPIO_ReadPin(GPIOC,GPIO_PIN_9)

#define AT24C02_ADDR    0x50  //1010000
#define AT24C02_ADDR_W  0xA0  //10100000
#define AT24C02_ADDR_R  0xA1  //10100001

#define WRITE_ERR1 1
#define WRITE_ERR2 2
#define WRITE_ERR3 3
#define WRITE_ERR4 4
#define WRITE_ERR5 5
#define WRITE_ERR6 6
#define WRITE_ERR7 7

#define READ_ERR1 11
#define READ_ERR2 22
#define READ_ERR3 33
#define READ_ERR4 44
#define READ_ERR5 55

#define  delay_us      delay_nus

void Iic3_config(void);
void IIC3_Start(void);
void IIC3_Stop(void);
uint8_t IIC3_Send_Byte(uint8_t data);
uint8_t IIC3_Revice_Byte(uint8_t ack);
uint8_t At24c02WriteByte(uint16_t addr,uint8_t data);
uint8_t At24c02ReadBytes(uint16_t addr,uint16_t num,uint8_t *p);
uint8_t At24c02PageWrite(uint16_t addr,uint8_t num,uint8_t *p);
uint8_t At24c02WriteBytes(uint16_t addr,uint16_t num,uint8_t *p);







#endif
